<?PHP
    /**
    * @brief Class About GCM Send
    * @file send.lib.php
    * @author Playplus (kimyh@playplus.co.kr)
    * @date 2013-04-10
    * @copyright Copyright (c) 2013, Playplus
    **/

    if (!defined("__PLAYPLUS__")) exit;

    class send {
        /**
         * Google Cloud Message Send (Curl Type)
         **/
        function gcm_curl_send ($r_code=array(), $apiKey="AIzaSyB82QO9Q7C_g3hMws8e7ckMER5ioBfSlg4", $message="TEST") {
            //$IDs=$r_code;
            $IDs=array("123456");
            $url='https://android.googleapis.com/gcm/send';
            $fields=array('registration_ids'=>$IDs, 'data'=>array("message"=>$message));
            $headers=array ('Authorization: key='.$apiKey, 'Content-Type:application/json');

            $ch=curl_init();
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_POST, true);
            curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));

            $result=curl_exec($ch);
            curl_close($ch);

            return $result;
        }
    }
?>